<?php echo view('header.html');?>

<body class="layui-view-body">
    <div class="layui-content">
        <div class="layui-row">
            <div class="layui-card">
                <div class="layui-card-header">
                    系统设置
                </div>
                <div class="layui-card-body">
                    <div class="form-box">
                        <form class="layui-form mokui-form" name="myform" lay-filter="myform" id="myform">
                            
                            <div class="layui-tab layui-tab-card">
                                <ul class="layui-tab-title">
                                    <li class="layui-this">基本设置</li>
                                    <li>后台设置</li>
                                    <li>域名设置</li>
                                    <li>移动端</li>
                                    <li>SEO设置</li>
                                    <li>图片水印</li>
                                </ul>
                                <div class="layui-tab-content">
                                    <!--1-->
                                    <div class="layui-tab-item layui-show">
                                        <div class="layui-form-item">
                                            <label class="layui-form-label">站点状态：</label>
                                            <div class="layui-input-inline">
                                                <div class="radio-list">
                                                    <input type="radio" lay-filter="site_close" name="data[SITE_CLOSE]" value="0" <?php if(empty($data['SITE_CLOSE']) || !$data['SITE_CLOSE']){?>checked<?php }?> title="开启" />
                                                    <input type="radio" lay-filter="site_close" name="data[SITE_CLOSE]" value="1" <?php if(isset($data['SITE_CLOSE']) && $data['SITE_CLOSE']==1){?>checked<?php }?> title="关闭" />
                                                </div>
                                            </div>
                                            <div class="layui-form-mid layui-word-aux">当关闭站点时，将无法访问网站（后台和静态页面 除外）</div>
                                        </div>
                                        <div class="layui-form-item ams_close_msg" style="display: none;">
                                            <label class="layui-form-label">关闭理由：</label>
                                            <div class="layui-input-inline">
                                                <textarea class="layui-textarea" name="data[SITE_CLOSE_MSG]"><?php echo isset($data['SITE_CLOSE_MSG']) ? $data['SITE_CLOSE_MSG'] : '系统升级中....';?></textarea>
                                            </div>
                                        </div>
                                        <div class="layui-form-item">
                                            <label class="layui-form-label">网站名称：</label>
                                            <div class="layui-input-inline">
                                                <label><input class="layui-input" type="text" name="data[SITE_NAME]" id="ams_name" value="<?=isset($data['SITE_NAME']) ? $data['SITE_NAME']: ''?>"></label>
                                            </div>
                                            <span class="layui-form-mid layui-word-aux">例如：官网</span>
                                        </div>

                                        <div class="layui-form-item">
                                            <label class="layui-form-label">HTTPS：</label>
                                            <div class="layui-input-inline">
                                                <div class="radio-list">
                                                    <input type="radio" name="data[SITE_HTTPS]" value="1" <?php if(isset($data['SITE_HTTPS']) && $data['SITE_HTTPS']==1){?>checked<?php }?> title="开启" />
                                                    <input type="radio" name="data[SITE_HTTPS]" value="0" <?php if((isset($data['SITE_HTTPS']) && $data['SITE_HTTPS']==0) || !isset($data['SITE_HTTPS'])){?>checked<?php }?> title="关闭" />
                                                </div>
                                            </div>
                                            <span class="layui-form-mid layui-word-aux">开启前需要保证服务器已经支持https协议，并且能够正常访问本系统</span>
                                        </div>

                                        <div class="layui-form-item">
                                            <label class="layui-form-label">系统语言：</label>
                                            <div class="layui-input-inline">
                                                <select name="data[SITE_LANGUAGE]">
                                                    <?php if(isset($lang) && $lang):?>
                                                    <?php foreach($lang as $t):?>
                                                    <option <?php if($t==$data['SITE_LANGUAGE']):?> selected="" <?php endif?> value="<?=$t?>"><?=$t?></option>
                                                    <?php endforeach?>
                                                    <?php endif?>
                                                </select>
                                            </div>
                                            <span class="layui-form-mid layui-word-aux"></span>
                                        </div>
                                    </div>
                                    <!--2-->
                                    <div class="layui-tab-item">
                                        <div class="layui-form-item">
                                            <label class="layui-form-label">默认分页数：</label>
                                            <div class="layui-input-inline">
                                                <input class="layui-input " type="text" name="data[SITE_ADMIN_PAGESIZE]" value="<?=isset($data['SITE_ADMIN_PAGESIZE']) ? $data['SITE_ADMIN_PAGESIZE'] : 10?>">
                                            </div>
                                            <span class="layui-form-mid layui-word-aux">例如文章每页显示的数量控制</span>
                                        </div>
                                        <div class="layui-form-item">
                                            <label class="layui-form-label">系统邮箱：</label>
                                            <div class="layui-input-inline">
                                                <input class="layui-input " type="text" name="data[SITE_EMAIL]" value="<?=isset($data['SITE_EMAIL']) ? $data['SITE_EMAIL'] : ''?>">
                                            </div>
                                            <span class="layui-form-mid layui-word-aux">用于接收系统发送的通知信息的可用邮箱</span>
                                        </div>
                                        <div class="layui-form-item">
                                            <label class="layui-form-label">网站安全密钥：</label>
                                            <div class="layui-input-inline" style="width: 300px;">
                                                <input class="layui-input " type="text" name="data[SITE_KEY]" id="ams_sitekey" value="<?=$data['SITE_KEY'] ?? ''?>">
                                            </div>
                                            <div class="layui-input-inline"><button class="layui-btn layui-btn-sm" type="button" name="button" onclick="ams_to_key()"> 重新生成</button></div>
                                            <span class="layui-form-mid layui-word-aux">密钥建议定期更换</span>
                                        </div>

                                        <div class="layui-form-item">
                                            <div class="layui-inline">
                                                <label class="layui-form-label">登录错误：</label>
                                                <div class="layui-input-inline" style="width:90px;">
                                                    <input class="layui-input " type="text" placeholder="后台登录错误几次后锁定" name="data[SITE_ADMIN_LOCK]" value="<?=isset($data['SITE_ADMIN_LOCK']) ? $data['SITE_ADMIN_LOCK'] : ''?>">
                                                </div>
                                                <span class="layui-form-mid layui-word-aux">次</span>
                                            </div>
                                            <div class="layui-inline">
                                                <label class="layui-form-label">锁定时长</label>
                                                <div class="layui-input-inline" style="width:90px;">
                                                    <input class="layui-input " type="text" placeholder="" name="data[SITE_ADMIN_LOCK_HOUR]" value="<?=isset($data['SITE_ADMIN_LOCK_HOUR']) ? $data['SITE_ADMIN_LOCK_HOUR'] : ''?>">
                                                </div>
                                                <span class="layui-form-mid layui-word-aux">分钟</span>
                                            </div>

                                        </div>

                                    </div>
                                    <!--3-->
                                    <div class="layui-tab-item">
                                        <div class="layui-form-item">
                                            <label class="layui-form-label">站点域名：</label>
                                            <div class="layui-input-inline">
                                                <input class="layui-input " type="text" name="data[SITE_DOMAIN]" id="ams_domain" value="<?=isset($data['SITE_DOMAIN']) ? $data['SITE_DOMAIN'] : ''?>">
                                            </div>
                                            <span class="layui-form-mid layui-word-aux" id="ams_domain_tips">例如：cms.baidu.com</span>
                                        </div>
                                        <div class="layui-form-item">
                                            <label class="layui-form-label">其他域名：</label>
                                            <div class="layui-input-inline">
                                                <textarea class="layui-textarea" style="height:150px" name="data[SITE_DOMAINS]"><?php isset($data['SITE_DOMAINS']) ? str_replace(',',PHP_EOL, $data['SITE_DOMAINS']) : ''?></textarea>
                                            </div>
                                            <span class="layui-form-mid layui-word-aux">当前站点支持绑定多个域名，它们将会301到主域名，域名之间以回车符分隔（请勿与其他站点的域名重复）</span>
                                        </div>
                                        <div class="layui-form-item">
                                            <label class="layui-form-label">URL唯一：</label>
                                            <div class="layui-input-inline">
                                                <div class="checkbox-list">
                                                    <input type="checkbox" name="data[SITE_URL_301]" value="1" <?php if(isset($data['SITE_URL_301']) && $data['SITE_URL_301']){echo 'checked';}?> title="启用">
                                                </div>
                                            </div>
                                            <span class="layui-form-mid layui-word-aux">启用将会使全站URL保持唯一，非当前URL自动301定向</span>
                                        </div>

                                    </div>
                                    <!--4-->
                                    <div class="layui-tab-item">
                                        <div class="layui-form-item">
                                            <label class="layui-form-label">自动切换移动端：</label>
                                            <div class="layui-input-inline">
                                                <input type="checkbox" name="data[SITE_MOBILE_OPEN]" value="1" {if $data['SITE_MOBILE_OPEN']}checked{/if} title="开启">
                                            </div>
                                            <span class="layui-form-mid layui-word-aux">开启后将自动识别移动端并强制定向到此域名</span>
                                        </div>
                                        <div class="layui-form-item">
                                            <label class="layui-form-label">移动端域名：</label>
                                            <div class="layui-input-inline">
                                                <label><input class="layui-input " type="text" name="data[SITE_MOBILE]" value="<?=isset($data['SITE_MOBILE']) ? $data['SITE_MOBILE'] : ''?>"></label>
                                            </div>
                                            <?php if(isset($data['SITE_MOBILE']) && isset($data['SITE_DOMAIN']) && $data['SITE_MOBILE'] == $data['SITE_DOMAIN']):?>
                                            <span class="layui-form-mid layui-word-aux">此域名不能与站点域名相同</span>
                                            <?php else:?>
                                            <span class="layui-form-mid layui-word-aux">格式：test.baidu.com</span>
                                            <?php endif?>
                                        </div>
                                    </div>
                                    <!--5-->
                                    <div class="layui-tab-item">
                                        <div class="layui-form-item">
                                            <label class="layui-form-label">SEO连接符：</label>
                                            <div class="layui-input-inline">
                                                <label><input class="layui-input " type="text" name="data[SITE_SEOJOIN]" value="<?=isset($data['SITE_SEOJOIN']) ? $data['SITE_SEOJOIN'] : '_'?>"></label>
                                            </div>
                                            <span class="layui-form-mid layui-word-aux">默认为"_"，如：文章标题[连接符]栏目名称[连接符]模型名称</span>
                                        </div>
                                        <div class="layui-form-item">
                                            <label class="layui-form-label">SEO标题：</label>
                                            <div class="layui-input-block">
                                                <input class="layui-input " type="text" name="data[SITE_TITLE]" value="<?=isset($data['SITE_TITLE']) ? $data['SITE_TITLE'] : ''?>">
                                            </div>
                                        </div>
                                        <div class="layui-form-item">
                                            <label class="layui-form-label">SEO关键字：</label>
                                            <div class="layui-input-block">
                                                <input class="layui-input " type="text" name="data[SITE_KEYWORDS]" value="<?=isset($data['SITE_KEYWORDS']) ? $data['SITE_KEYWORDS'] : ''?>">
                                            </div>
                                        </div>
                                        <div class="layui-form-item">
                                            <label class="layui-form-label">SEO描述信息：</label>
                                            <div class="layui-input-block">
                                                <textarea class="layui-textarea" name="data[SITE_DESCRIPTION]"><?=isset($data['SITE_DESCRIPTION']) ? $data['SITE_DESCRIPTION'] : ''?></textarea>
                                            </div>
                                        </div>
                                    </div>
                                    <!--6-->
                                    <div class="layui-tab-item">
                                        <div class="layui-form-item">
                                            <label class="layui-form-label">保持纵横比例：</label>
                                            <div class="layui-input-inline">
                                                <input type="checkbox" name="data[SITE_IMAGE_RATIO]" value="1" <?=(isset($data['SITE_IMAGE_RATIO']) && $data['SITE_IMAGE_RATIO']) ? 'checked' : ''?> title="开启">
                                            </div>
                                            <span class="layui-form-mid layui-word-aux">指定是否在缩放或使用硬值的时候使图像保持原始的纵横比例</span>
                                        </div>
                                        <div class="layui-form-item">
                                            <label class="layui-form-label">图片水印总开关：</label>
                                            <div class="layui-input-inline">
                                                <input type="radio" lay-filter="site_image_watermark" name="data[SITE_IMAGE_WATERMARK]" value="1" <?=(isset($data['SITE_IMAGE_WATERMARK']) && $data['SITE_IMAGE_WATERMARK']) ? 'checked' : ''?> title="开启" />
                                                <input type="radio" lay-filter="site_image_watermark" name="data[SITE_IMAGE_WATERMARK]" value="0" <?=(!isset($data['SITE_IMAGE_WATERMARK']) || !$data['SITE_IMAGE_WATERMARK']) ? 'checked' : ''?> title="关闭" />
                                            </div>
                                        </div>
                                        <div class="layui-form-item ams_image">
                                            <label class="layui-form-label">远程附件水印：</label>
                                            <div class="layui-input-inline">
                                                <input type="checkbox" name="data[SITE_IMAGE_REMOTE]" value="1" <?=(isset($data['SITE_IMAGE_REMOTE']) && $data['SITE_IMAGE_REMOTE']) ? 'checked' : ''?> title="开启">
                                            </div>
                                            <span class="layui-form-mid layui-word-aux">打开远程附件水印会降低服务器性能，建议远程附件不加水印</span>
                                        </div>
                                        <div class="layui-form-item ams_image">
                                            <label class="layui-form-label">编辑器图片水印：</label>
                                            <div class="layui-input-inline">
                                                <input type="checkbox" name="data[SITE_IMAGE_CONTENT]" value="1" <?=(isset($data['SITE_IMAGE_CONTENT']) && $data['SITE_IMAGE_CONTENT']) ? 'checked' : ''?> title="开启">
                                            </div>
                                            <span class="layui-form-mid layui-word-aux">开启后文章编辑器内容中上传的图片将会采用动态水印模式</span>
                                        </div>
                                        <div class="layui-form-item ams_image">
                                            <label class="layui-form-label">对齐方式：</label>
                                            <div class="layui-input-inline">
                                                <select name="data[SITE_IMAGE_VRTALIGN]">
                                                    <?php if(isset($wm_hor_alignment) && $wm_hor_alignment):?>
                                                    <?php foreach($wm_vrt_alignment as $t):?>
                                                    <option <?php if($t==$data['SITE_IMAGE_VRTALIGN']){echo 'selected';}?> value="<?=$t?>"><?=$t?></option>
                                                    <?php endforeach?>
                                                    <?php endif?>
                                                </select>
                                            </div>
                                            <div class="layui-input-inline">
                                                <select name="data[SITE_IMAGE_HORALIGN]">
                                                    <?php if(isset($wm_hor_alignment) && $wm_hor_alignment):?>
                                                    <?php foreach($wm_hor_alignment as $t):?>
                                                    <option <?php if($t==$data['SITE_IMAGE_HORALIGN']){echo 'selected';}?> value="<?=$t?>"><?=$t?></option>
                                                    <?php endforeach?>
                                                    <?php endif?>
                                                </select>
                                            </div>
                                        </div>
                                        <div class="layui-form-item ams_image">
                                            <label class="layui-form-label">偏移量设置：</label>
                                            <div class="layui-input-inline">
                                                <input class="layui-input " type="text" name="data[SITE_IMAGE_VRTOFFSET]" value="<?=isset($data['SITE_IMAGE_VRTOFFSET']) ? $data['SITE_IMAGE_VRTOFFSET'] : ''?>" />
                                            </div>
                                            <div class="layui-input-inline">
                                                <input class="layui-input " type="text" name="data[SITE_IMAGE_HOROFFSET]" value="<?=isset($data['SITE_IMAGE_HOROFFSET']) ? $data['SITE_IMAGE_HOROFFSET'] : ''?>" />
                                            </div>
                                            <span class="layui-form-mid layui-word-aux">这里可以设置水印图片/文字的偏移量来校正图片水印位置</span>
                                        </div>
                                        <div class="layui-form-item ams_image">
                                            <label class="layui-form-label">水印方式：</label>
                                            <div class="layui-input-inline">
                                                <input type="radio" class="dtype" name="data[SITE_IMAGE_TYPE]" value="1" lay-filter="ams_set_mw_type" <?=(isset($data['SITE_IMAGE_TYPE']) && $data['SITE_IMAGE_TYPE']) ? 'checked' : ''?> title="图片水印" />
                                            </div>
                                            <div class="layui-input-inline">
                                                <input type="radio" class="dtype" name="data[SITE_IMAGE_TYPE]" value="0" lay-filter="ams_set_mw_type" <?=(!isset($data['SITE_IMAGE_TYPE']) || !$data['SITE_IMAGE_TYPE']) ? 'checked' : ''?> title="文字水印" />
                                            </div>
                                        </div>
                                        <div class="layui-form-item ams_image ams_mw_1" style="display:none">
                                            <label class="layui-form-label">选择水印图片：</label>
                                            <div class="layui-input-inline">
                                                <select name="data[SITE_IMAGE_OVERLAY]">
                                                    <?php if(isset($wm_opacity) && $wm_opacity):?>
                                                    <?php foreach($wm_opacity as $t):?>
                                                    <option <?php if($t==$data['SITE_IMAGE_OVERLAY']){echo 'selected';}?> value="<?=$t?>"><?=$t?></option>
                                                    <?php endforeach?>
                                                    <?php endif?>
                                                </select>
                                            </div>
                                            <span class="layui-form-mid layui-word-aux">图片目录：“根目录/assets/public/watermark/”，必须是png格式的图片</span>
                                        </div>
                                        <div class="layui-form-item ams_mw_1 ams_image" style="display:none">
                                            <label class="layui-form-label">图像不透明度：</label>
                                            <div class="layui-input-inline">
                                                <input class="layui-input " type="text" name="data[SITE_IMAGE_OPACITY]" value="<?=isset($data['SITE_IMAGE_OPACITY']) ? $data['SITE_IMAGE_OPACITY'] : ''?>" />
                                            </div>
                                            <span class="layui-form-mid layui-word-aux">这将使水印模糊化，从而不会掩盖住底层原始图片的细节，通常设置为50</span>
                                        </div>
                                        <div class="layui-form-item ams_mw_0 ams_image" style="display:none">
                                            <label class="layui-form-label">文字字体：</label>
                                            <div class="layui-input-inline">
                                                <select name="data[SITE_IMAGE_FONT]">
                                                    <?php if(isset($wm_font_path) && $wm_font_path):?>
                                                    <?php foreach($wm_font_path as $t):?>
                                                    <option <?php if($t==$data['SITE_IMAGE_FONT']){echo 'selected';}?> value="<?=$t?>"><?=$t?></option>
                                                    <?php endforeach?>
                                                    <?php endif?>
                                                </select>
                                            </div>
                                            <span class="layui-form-mid layui-word-aux">字体目录：“根目录/assets/watermark/”，必须是ttf格式的字体文件</span>
                                        </div>
                                        <div class="layui-form-item ams_mw_0 ams_image" style="display:none">
                                            <label class="layui-form-label">字体大小：</label>
                                            <div class="layui-input-inline">
                                                <input class="layui-input " type="text" name="data[SITE_IMAGE_SIZE]" value="<?=isset($data['SITE_IMAGE_SIZE']) ? $data['SITE_IMAGE_SIZE'] : ''?>" />
                                            </div>
                                        </div>
                                        <div class="layui-form-item ams_mw_0 ams_image" style="display:none">
                                            <label class="layui-form-label">水印文字：</label>
                                            <div class="layui-input-inline">
                                                <input class="layui-input " type="text" name="data[SITE_IMAGE_TEXT]" value="<?=isset($data['SITE_IMAGE_TEXT']) ? $data['SITE_IMAGE_TEXT'] : ''?>" />
                                            </div>
                                        </div>
                                    </div>
                                </div>

                                <div class="layui-form-item">
                                    <label class="layui-form-label"></label>
                                    <div class="layui-input-block">
                                        <button class="layui-btn layui-btn-blue" lay-submit="" lay-filter="ams_submit">提交保存</button>
                                    </div>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
</body>
<?php echo view('footer.html');?>
<script type="text/javascript">
    layui.use(['layer', 'form', 'jquery', 'element'], function () {
        var layer = layui.layer,
            $ = layui.jquery,
            form = layui.form,
            element = layui.element;

        //站点开关
        form.on('radio(site_close)', function (data) {
            if (data.value == 1) {
                $('.ams_close_msg').show()
            } else {
                $('.ams_close_msg').hide()
            }
        });
        //水印总开关
        form.on('radio(site_image_watermark)', function (data) {
            if (data.value == 1) {
                $('.ams_image').show();
            } else {
                $('.ams_image').hide();
            }
            var id = $(".dtype:checked").val();
            $(".ams_mw_1").hide();
            $(".ams_mw_0").hide();
            $(".ams_mw_" + id).show();
            form.render();
        });
        //水印方式
        form.on('radio(ams_set_mw_type)', function (data) {
            var id = data.value;
            $(".ams_mw_1").hide();
            $(".ams_mw_0").hide();
            $(".ams_mw_" + id).show();
            form.render();
        });
        //提交
        form.on('submit(ams_submit)', function (data) {
            $.post(adminpath + "admin/system/index", data.field, function (res) {
                if (res.code == 0) {
                    layer.msg('操作成功， 正在刷新...', { time: 1000 }, function () {
                        location.reload();
                    });
                } else {
                    layer.msg(res.msg, { icon: 5 });
                }
            }, 'json');
            return false;
        });
    });
</script>
